//-----------------------------------------------------------------------
// <copyright file="CustomerProductService.cs" company="Pyramid Consulting">
//     Copyright (c) Pyramid Consulting. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using MyFramework;
using MIMS.WRS.Entities;
using MIMS.WRS.Data;
    
namespace MIMS.WRS.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class CustomerProductService
    {
		public static CustomerProductCollection GetCustomerProducts(int userID, CustomerProductColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
		{            
			try
			{
				CustomerProductDAO customerProductDAO = new CustomerProductDAO();
				return customerProductDAO.GetCustomerProducts(userID, orderBy, orderDirection, page, pageSize, out totalRecords);
			}
			catch (BusinessException)
			{
				throw;
			}
			catch (Exception ex)
			{
				// log this exception
				Logger.Error(ex);
				// wrap it and rethrow
				throw new BusinessException(SR.BusinessGetCustomerProductsException, ex);
			}
		}   

		#region CustomerProduct

		public static void CreateCustomerProduct(CustomerProduct customerProduct)
		{            
			try
			{
				CustomerProductDAO customerProductDAO = new CustomerProductDAO();
				customerProductDAO.CreateCustomerProduct(customerProduct);
			}
			catch (BusinessException)
			{
				throw;
			}
			catch (Exception ex)
			{
				// log this exception
				Logger.Error(ex);
				// wrap it and rethrow
				throw new BusinessException(SR.BusinessCreateCustomerProductException, ex);
			}
		}        

		public static void UpdateCustomerProduct(CustomerProduct customerProduct)
		{            
			try
			{
				CustomerProductDAO customerProductDAO = new CustomerProductDAO();
				customerProductDAO.UpdateCustomerProduct(customerProduct);
			}
			catch (BusinessException)
			{
				throw;
			}
			catch (Exception ex)
			{
				// log this exception
				Logger.Error(ex);
				// wrap it and rethrow
				throw new BusinessException(SR.BusinessUpdateCustomerProductException, ex);
			}
		}        

		public static void DeleteCustomerProduct(int userID, string productCode)
		{            
			try
			{
				CustomerProductDAO customerProductDAO = new CustomerProductDAO();
				customerProductDAO.DeleteCustomerProduct(userID, productCode);
			}
			catch (BusinessException)
			{
				throw;
			}
			catch (Exception ex)
			{
				// log this exception
				Logger.Error(ex);
				// wrap it and rethrow
				throw new BusinessException(SR.BusinessDeleteCustomerProductException, ex);
			}
		}
        
		public static CustomerProduct GetCustomerProduct(int userID, string productCode)
		{            
			try
			{
				CustomerProductDAO customerProductDAO = new CustomerProductDAO();
				return customerProductDAO.GetCustomerProduct(userID, productCode);                
			}
			catch (BusinessException)
			{
				throw;
			}
			catch (Exception ex)
			{
				// log this exception
				Logger.Error(ex);
				// wrap it and rethrow
				throw new BusinessException(SR.BusinessGetCustomerProductException, ex);
			}
		}                

		public static CustomerProductCollection GetCustomerProducts(CustomerProductColumns orderBy, OrderDirection orderDirection)
		{            
			try
			{
				CustomerProductDAO customerProductDAO = new CustomerProductDAO();
				return customerProductDAO.GetCustomerProducts(orderBy, orderDirection);
			}
			catch (BusinessException)
			{
				throw;
			}
			catch (Exception ex)
			{
				// log this exception
				Logger.Error(ex);
				// wrap it and rethrow
				throw new BusinessException(SR.BusinessGetCustomerProductsException, ex);
			}
		}        

		public static CustomerProductCollection GetCustomerProducts(CustomerProductColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
		{            
			try
			{
				CustomerProductDAO customerProductDAO = new CustomerProductDAO();
				return customerProductDAO.GetCustomerProducts(orderBy, orderDirection, page, pageSize, out totalRecords);
			}
			catch (BusinessException)
			{
				throw;
			}
			catch (Exception ex)
			{
				// log this exception
				Logger.Error(ex);
				// wrap it and rethrow
				throw new BusinessException(SR.BusinessGetCustomerProductsException, ex);
			}
		}        

		#endregion

    }
}